<?
/*	TEMPLATE META
	Name: The Loop
*/
if((drizzo_is_page('blog') || drizzo_is_page('asides') || drizzo_is_page('index')) && !$drizzo_post_id) { // If this is the index or is /blog
	$the_posts = drizzo_get_the_posts(); // Start the Loop
	foreach($the_posts as $the_post) { // Loop through the posts
?>
		<div class="post">
			<h2><a href="<? echo drizzo_post_permalink(); ?>" title="<? echo drizzo_post_title(); ?>"><? echo drizzo_post_title(); ?></a><? if(drizzo_user_has_avatar()) { ?><img src="<? echo admin_folder . "engine/user_avatar.php?user_id=" . $the_post['author']; ?>" alt="<? echo drizzo_post_author("display_name"); ?>" class="post_avatar" /><? } ?></h2>
			<p class="post_meta meta_top">By <? echo drizzo_post_author("display_name"); ?> on <? echo drizzo_post_date(drizzo_global_options('date_format') . ' \a\t ' . drizzo_global_options('time_format'))?></p>
			<div class="post_content"><? if(drizzo_global_options('use_excerpts') == 1) { echo drizzo_post_excerpt(); } else { echo drizzo_post_content(); } ?></div>
			<p class="post_meta meta_bottom"><span class="tags_meta"><strong>Tags:</strong> <? echo drizzo_post_tags(); ?></span> | <span class="comments_meta"><strong><a href="<? echo drizzo_post_permalink(); ?>#comments" title="View Comments">Comments:</strong> <? echo drizzo_comment_count(); ?></a></span><? echo drizzo_edit_link(" | ", ""); ?></p>
		</div>
<?
	} // End loop through the posts
} elseif((drizzo_is_page('blog') || drizzo_is_page('asides') || drizzo_is_page('index')) && $drizzo_post_id) { // Show an individual blog post
	$the_post = (drizzo_get_the_post($drizzo_post_id)); // Get the post
?>
		<div class="post">
			<h2><a href="<? echo drizzo_post_permalink(); ?>" title="<? echo drizzo_post_title(); ?>"><? echo drizzo_post_title(); ?></a><? if(drizzo_user_has_avatar()) { ?><img src="<? echo admin_folder . "engine/user_avatar.php?user_id=" . $the_post['author']; ?>" alt="<? echo drizzo_post_author("display_name"); ?>" class="post_avatar" /><? } ?></h2>

			<p class="post_meta meta_top">By <? echo drizzo_post_author("display_name"); ?> on <? echo drizzo_post_date(); ?></p>
			<div class="post_content">
			<? echo drizzo_post_content(); ?>
			</div>
			<p class="post_meta meta_bottom"><span class="tags_meta"><strong>Tags:</strong> <? echo drizzo_post_tags(); ?></span><? echo drizzo_edit_link(" | ", ""); ?></p>

		</div>

		<hr />

		<? include('comments.php');	?>

<?
} elseif(drizzo_is_page('events')) { // Show the events
	$the_events = drizzo_events();
	if(is_array($the_events)) {
		foreach($the_events as $the_event) {
?>
			<div class="event">
				<h2><a href="<? echo drizzo_event_permalink(); ?>" title="<? echo $the_event['what']?>"><? echo $the_event['what']?></a></h2>
				<p class="event_meta meta_top"><? echo $the_event['start'] . " - " . $the_event['end'];?></p>
				<div class="event_content">
					<p><? echo $the_event['where']; if(strlen($the_event['address']) > 0) { echo ", $the_event[address]"; } ?></p>
					<? if (strlen($the_event['who']) > 0) { echo "<p>$the_event[who]</p>"; } ?>
					<? if (strlen($the_event['notes']) > 0) { echo "$the_event[notes]"; } ?>
				</div>
				<p class="event_meta meta_bottom"><span class="tags_meta"><strong>Tags:</strong> <? echo drizzo_event_tags(); ?></span><? echo drizzo_edit_link(" | ", ""); ?>
			</div>
<?			
		}
	} elseif(isset($the_events)) {
		echo $the_events;
	} else {
		echo "<p>No events could be found.</p>";
	}
	echo drizzo_events_prev_and_next();
} elseif(drizzo_is_page('gallery')) {
	echo drizzo_gallery();
	include('comments.php');
} elseif(drizzo_is_page('tags')) {
	$the_posts = (drizzo_tag_search($drizzo_post_id)); // Start the Loop
	if(count($the_posts) > 0) {
		foreach($the_posts as $the_post) {
?>
		<div class="post">
			<h2><a href="<? echo drizzo_post_permalink(); ?>" title="<? echo drizzo_post_title(); ?>"><? echo drizzo_post_title(); ?></a></h2>
			<p class="post_meta">By <? echo drizzo_post_author("nice_name"); ?> on <? echo drizzo_post_date(); ?></p>

			<p class="content"><? echo drizzo_post_excerpt(); ?></p>

			<p class="post_meta"><span class="tags_meta"><strong>Tags:</strong> <? echo drizzo_post_tags(); ?></span> | <span class="comments_meta"><strong><a href="<? echo drizzo_post_permalink(); ?>#comments" title="View Comments">Comments:</strong> <? echo drizzo_comment_count(); ?></a></span><? echo drizzo_edit_link(" | ", ""); ?></p>
		</div>

<?
		}
	} else {
?>
		<div class="post">
			<p>No posts were found under that tag. Maybe one of these others will help.</p>
<? echo drizzo_tag_cloud(); ?>
		</div>
<?		
	}
} elseif(drizzo_is_page('page')) {
	$the_post = (drizzo_get_the_post($drizzo_post_id)); // Start the Loop
?>
		<div class="post">
			<h2><a href="<? echo drizzo_post_permalink(); ?>"><? echo drizzo_post_title(); ?></a></h2>

			<p class="content"><? echo drizzo_post_content(); ?></p>

			<p class="post_meta">By <? echo drizzo_post_author("nice_name"); ?> on <? echo drizzo_post_date(); ?><br />
			<span class="tags_meta"><strong>Tags:</strong> <? echo drizzo_post_tags(); ?></span> <? echo drizzo_edit_link(" | ", ""); ?></p>
		</div>

		<hr />

<?	
	include('comments.php');
}
?>
